package com.learn.algorlthm;

/**
 * @classname:
 * @Description: 二叉树的镜像
 * @author: yfpu(fengpu.yang @ ucarinc.com)
 * @Date: 2018-07-30 09:23
 * 题目描述：
 * 操作给定的二叉树，将其变换为源二叉树的镜像。
 */
public class Learn27 {

    public static void Mirror(TreeNode root) {
        if (root == null)
            return;

        swap(root);
        Mirror(root.left);
        Mirror(root.right);

    }

    private static void swap(TreeNode root) {
        TreeNode t = root.left;
        root.left = root.right;
        root.right = t;
    }




    class TreeNode {
        public int val;
        public TreeNode left;
        public TreeNode right;
    }

}
